﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Doctor/ViewMasterPage.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <title>Index</title>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">
        <div class="row">
            <ol class="breadcrumb">
                <li><a href="#"><span class="glyphicon glyphicon-home"></span></a></li>
                <li class="active">医生</li>
            </ol>
        </div>
        <!--/.row-->

        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">医生</h1>
            </div>
        </div>
        <!--/.row-->

        <div class="row">
            <div class="col-xs-12 col-md-6 col-lg-3">
                <div class="panel panel-blue panel-widget ">
                    <div class="row no-padding">
                        <div class="col-sm-3 col-lg-5 widget-left">
                            <em class="glyphicon glyphicon-shopping-cart glyphicon-l"></em>
                        </div>
                        <div class="col-sm-9 col-lg-7 widget-right">
                            <div class="large">120</div>
                            <div class="text-muted">设备数量</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12 col-md-6 col-lg-3">
                <div class="panel panel-orange panel-widget">
                    <div class="row no-padding">
                        <div class="col-sm-3 col-lg-5 widget-left">
                            <em class="glyphicon glyphicon-comment glyphicon-l"></em>
                        </div>
                        <div class="col-sm-9 col-lg-7 widget-right">
                            <div class="large">52</div>
                            <div class="text-muted">通信数量</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12 col-md-6 col-lg-3">
                <div class="panel panel-teal panel-widget">
                    <div class="row no-padding">
                        <div class="col-sm-3 col-lg-5 widget-left">
                            <em class="glyphicon glyphicon-user glyphicon-l"></em>
                        </div>
                        <div class="col-sm-9 col-lg-7 widget-right">
                            <div class="large">24</div>
                            <div class="text-muted">用户数量</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12 col-md-6 col-lg-3">
                <div class="panel panel-red panel-widget">
                    <div class="row no-padding">
                        <div class="col-sm-3 col-lg-5 widget-left">
                            <em class="glyphicon glyphicon-stats glyphicon-l"></em>
                        </div>
                        <div class="col-sm-9 col-lg-7 widget-right">
                            <div class="large">25.2</div>
                            <div class="text-muted">记录数据</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--/.row-->

        <div class="row">
            <div class="col-md-8">
                <div class="panel panel-default">
                    <div class="panel-heading"><span class="glyphicon glyphicon-envelope"></span>发送邮箱</div>
                    <div class="panel-body">
                        <form class="form-horizontal" action="" method="post">
                            <fieldset>
                               
                                <!-- Name input-->
                                <div class="form-group">
                                    <label class="col-md-3 control-label" for="name" >姓名</label>
                                    <div class="col-md-9">
                                        <input id="name" name="name" type="text" placeholder="真实姓名" class="form-control" >
                                    </div>
                                </div>

                                <!-- Email input-->
                                <div class="form-group">
                                    <label class="col-md-3 control-label" for="email" >邮箱</label>
                                    <div class="col-md-9">
                                        <input id="email" name="email" type="text" placeholder="邮箱地址" class="form-control" >
                                    </div>
                                </div>

                                <!-- Message body -->
                                <div class="form-group">
                                    <label class="col-md-3 control-label" for="message">消息</label>
                                    <div class="col-md-9">
                                        <textarea class="form-control" id="message" name="" placeholder="请输入你要发送的内容" rows="5" ></textarea>
                                    </div>
                                </div>

                                <!-- Form actions -->
                                <div class="form-group">
                                    <div class="col-md-12 widget-right">
                                        <button type="submit" class="btn btn-default btn-md pull-right" id="but_send">发送</button>
                                    </div>
                                </div>
                            </fieldset>
                        </form>
                    </div>
                </div>



            </div>
            <!--/.col-->
            <div class="col-md-4">
                <div class="panel panel-default chat">
                    <div class="panel-heading" id="accordion"><span class="glyphicon glyphicon-comment"></span>聊天</div>

                    <div class="panel-body">
                        <ul id="ul_talk">
                        </ul>
                    </div>

                    <div class="panel-footer">
                        <div class="input-group">
                            <input id="btn-input" type="text" class="form-control input-md" placeholder="填写消息。。。" />
                            <span class="input-group-btn">
                                <button class="btn btn-success btn-md" id="btn-chat">发送</button>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
            <!--/.row-->
        </div>
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="JsContent" runat="server">
<script>

    $('#but_send').click(function () {
        $.post(
            "/Doctor/SendEmail",
        { "Name":$('#name').val()  ,
        "Email":$('#email').val(),
        "Chars": $('#message').val()
        },
            function (data) {
                if (data == "OK") {
                    alert("发送成功");
                }
                else if (data == "No") {
                    alert("发送失败");
                    $('#message').val("  ");
                }
                else {
                    alert("请检查信息是否完整");
                } 
            }
        );
    });

    $(document).ready(function () {
        List();
    });

    $('#btn-chat').click(function () {
        $.post("/Doctor/AddTalk", {
            "mess":$('#btn-input').val()
        }, function (data) {
            if (data == "OK") {
                List();
            }
            else {
                alert("发送失败");
            }
        });
    });

    function List() {
        $.post("/Doctor/GetTalk", {}, function (data) {
            var html_list = new Array();
            var html_str = "";
            var i = 0;
            if (data) {
                for (i = 0; i < 10; i++) {
                    if (data[i]) {
                        if (data[i].Talker != data[i].UserName) {
                            html_list[i] = "<li class='right clearfix'><span class='chat-img pull-right'><img src='http://placehold.it/80/30a5ff/fff' alt='User Avatar' class='img-circle' /></span><div class='chat-body clearfix'><div class='header'><strong class='pull-left primary-font'>" + data[i].Talker + "</strong> <small class='text-muted'>" + data[i].Time_Str + "</small></div><p>" + data[i].Talk + "</p></div></li>"; //data[i];
                        }
                        else {
                            html_list[i] = ("<li class='left clearfix'><span class='chat-img pull-left'><img src='http://placehold.it/80/dde0e6/5f6468' alt='User Avatar' class='img-circle' /></span><div class='chat-body clearfix'><div class='header'><strong class='primary-font'>" + data[i].Talker + "</strong> <small class='text-muted'>" + data[i].Time_Str + "</small></div><p>" + data[i].Talk + "</p></div></li>");
                        }
                    }
                }
                $("#ul_talk").html(html_list);
            }
        });
    }
    window.setInterval(List, 2000);
</script>
</asp:Content>


<asp:Content ID="Content3" ContentPlaceHolderID="LeftMenuContent" runat="server">
    <li><a href="/Doctor/Index"><span class="glyphicon glyphicon-dashboard"></span>首页</a></li>
    <li  class="active"><a href="/Doctor/Widgets"><span class="glyphicon glyphicon-th"></span>沟通</a></li>
	<li><a href="/Doctor/Charts"><span class="glyphicon glyphicon-stats"></span>监测仪</a></li>
	<li><a href="/Doctor/Tables"><span class="glyphicon glyphicon-list-alt"></span>客户</a></li>
	<li ><a href="/Doctor/Forms"><span class="glyphicon glyphicon-pencil"></span>病历</a></li>
	<li><a href="/Doctor/Panels"><span class="glyphicon glyphicon-info-sign"></span>计划</a></li>
</asp:Content>
